package com.example.chaomi;

import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ListView;

public class FG2 extends Fragment {
	public FG2() {
		
	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saved) {
		View view = inflater.inflate(R.layout.fg, null);
		final ListView  lv = (ListView) view.findViewById(R.id.fg_lv);
		Log.d("lijh", "getActivity():"+getActivity().toString());
		lv.setAdapter(new TitleAdapter2(getActivity()));
		lv.requestFocus();
		lv.post(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				//lv.getChildAt(1).setSelected(true);
				lv.setSelection(MainActivity.mPos);;
			}
		});
		lv.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				// TODO Auto-generated method stub
				FormatDisk formatDisk = new FormatDisk(getActivity());
				formatDisk.format(formatDisk.getVolumeInfos().get(arg2));
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		return view;
		
	}

}
